<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: consolas;
        }

        section {
            position: relative;
            width: 100%;
            height: 100vh;
            overflow: hidden;
            background: #111;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        section h2 {
            font-size: 10em;
            color: #333;
        }

        section span {
            position: absolute;
            bottom: 0px;
            background: transparent;
            border-radius: 50%;
            /* 就是鼠标事件拜拜的意思 */
            pointer-events: none;
            box-shadow: inset 0 0 10px rgba(255, 255, 255, .5);
            animation: animate 4s linear infinite;
        }

        @keyframes animate {
            0% {
                transform: translateY(0%);
                opacity: 1;
            }

            100% {
                transform: translateY(-1200%);
                opacity: 1;
            }
        }
    </style>
</head>

<body>
    <section>
        <h2>Bubbles</h2>
    </section>
</body>
<script>
    function createBubble() {
        const section = document.querySelector('section')
        const createElement = document.createElement('span')
        var size = Math.random() * 60;

        createElement.style.width = 20 + size + 'px';
        createElement.style.height = 20 + size + 'px';
        createElement.style.left = Math.random() * innerWidth + 'px';
        section.appendChild(createElement);

        setTimeout(() => {
            createElement.remove()
        }, 4000)
    }

    setInterval(createBubble, 50)
</script>

</html>